/**
  ******************************************************************************
  * @file 
  * @brief 比例阀控制
  * @author luffy
  * @version V1.0.0
  * @date 2022/12/14
  ******************************************************************************
  */

#ifndef _VALVE_CTL_TASK_H
#define _VALVE_CTL_TASK_H

#include <stdint.h>
#include "func_pid.h"
/* Public defines -----------------------------------------------------------*/

/* Public Struct -----------------------------------------------------------*/
//比例阀控制数据结构
typedef struct VALVECTRL_tag
{
    func_pid_t     bleedPid;                 //抽气比例阀控制PID参数
	func_pid_t     blowPid;                  //充气比例阀控制PID参数
    float          presAccuracy;             //基体腔压力控制精度，单位mA
    float          presFilterSave;           //RC滤波的压力保存值   
    float          presSave;                 //压力保存值，浮点数，用于比例阀控制计算
    float          presFilterK;              //滤波系数
    float          valveVoltage;             //比例阀电压,范围0~3.3V
    float          pressure;                 //基体腔实时压力值，单位Pa
	float          speed;                    //压力变化速率Pa/s
    int            waitingTime;              //压力控制稳定时间
    int            readytimer;               //压力的稳定判断时间计数
    int            presStable;               //压力稳定标识，ture：稳定；false：不稳定   
	int            overTime;                 //压力控制超时时间
	uint16_t       sampleCycle;              //PID采集周期
	uint8_t        presCtrlEn;               //控制使能
	uint8_t        pidSwitch;                //pid参数切换 0:抽气 1:充气
} VALVECTRL,*PVALVECTRL;
/* Public enum -----------------------------------------------------------*/
enum {
    pres_task_read_pres    = 0,
    pres_task_read_alarm,
    pres_task_read_target,
    pres_task_read_pid,
};

enum {
    pres_task_set_alarm  = 0,
    pres_task_set_target,
    pres_task_set_pid,
};

enum {
    BLEED_PID  = 0,
    BLOW_PID,
};
/* Public Variable ---------------------------------------------------------*/
//Pointer
extern VALVECTRL  BODYPRESCTRL; 
//Array

//Const

/* Pubilc function prototypes -----------------------------------------------*/
void PCON_Thread(void *pvParameters);
uint8_t PresTaskRead(uint8_t cmd, void *par);
uint8_t PresTaskSet(uint8_t cmd, void *par);
void PCON_Init(void);

#endif /* _LNCUP_CTL_TASK_H */

/******************* (C) COPYRIGHT 2022 CIQTEK luffy *****END OF FILE****/
